import { Database } from 'bun:sqlite';
import { drizzle } from 'drizzle-orm/bun-sqlite';
import * as schema from './schema';

// 创建数据库连接
const sqlite = new Database('./database.sqlite');

// 启用外键约束
sqlite.exec('PRAGMA foreign_keys = ON');

// 创建 Drizzle 实例
export const db = drizzle(sqlite, { schema });

// 导出所有表
export { 
  users, 
  products, 
  cases, 
  tags,
  settings, 
  uploads, 
  systemLogs,
  backups,
  contacts
} from './schema';